# Contributor: kpcyrd <git@rxv.cc>
# Maintainer: kpcyrd <git@rxv.cc>
pkgname=acmetool
pkgver=0.0.67
pkgrel=2
pkgdesc="An easy-to-use command line tool for automatically acquiring certificates from ACME servers (such as Let's Encrypt)"
url="https://github.com/hlandau/acme"
arch="all"
license="MIT"
makedepends="glide go libcap-dev"
subpackages="$pkgname-doc"
# no test suite available
options="!check"
source="$pkgname-$pkgver.tar.gz::https://github.com/hlandau/acme/archive/v$pkgver.tar.gz
	glide.lock
	glide.yaml
	"
builddir="$srcdir/src/github.com/hlandau/acme"

prepare() {
	mkdir -p ${builddir%/*}
	mv "$srcdir/acmetool-$pkgver" "$builddir"
	cd "$builddir"
	cp "$srcdir"/glide.yaml "$srcdir"/glide.lock .
	export GOPATH="$srcdir"
	glide install --skip-test
	default_prepare
}

build() {
	cd "$builddir"
	export GOPATH="$srcdir"
	go build -v -ldflags "-s -w -X github.com/hlandau/acme/hooks.DefaultPath=/etc/acme/hooks" \
		./cmd/acmetool/...
}

package() {
	cd "$builddir"
	install -Dm 755 acmetool "$pkgdir/usr/bin/acmetool"

	install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README"
	install -Dm644 _doc/* -t "$pkgdir/usr/share/doc/$pkgname/"
}

glide_init() {
	abuild clean deps unpack prepare
	cd "$builddir"
	export GOPATH="$srcdir"
	rm -f glide.yaml glide.lock
	glide init --non-interactive
	glide update
	cp glide.yaml glide.lock "$startdir"
	cd "$startdir" && abuild checksum clean
}

sha512sums="b0c3013167ceee6c1e577cf1678c256ffed243e8aa5038d86836e625a7c484fd5ca2bb79feb1cae981afc49a6e1635b62b23e58d11a86cc9c1e5012d9e0a638a  acmetool-0.0.67.tar.gz
6ea636b99e3a2cab73e52a75bc92430fae6515d00c3287f5bbe942666e8fbba0883a3a89a6930021c7aae4451c4a9586eb034c35282d0e331d2f7b8456897bca  glide.lock
108403fb50acdc3f74ad02d07b22665192206db8450a94156c57e129577835663f36c1a7fd40bd924bc84297c07417465b8013d9262bc497b74c000c268c7d42  glide.yaml"
